﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary
{
    /// <summary>
    /// This class represents a description of a linear equation system.
    /// </summary>
    [Serializable]
    public class LinearEquationSystem
    {
        /// <summary>
        /// The coefficient matrix of the linear equation system.
        /// </summary>
        private Matrix coefficientMatrix;

        /// <summary>
        /// The result vector of the linear equation system.
        /// </summary>
        private GeneralVector resultVector;

        /// <summary>
        /// Initializes a new instance of the <see cref="LinearEquationSystem"/> class.
        /// </summary>
        /// <param name="coefficientMatrix">The coefficient matrix of the linear equation system.</param>
        /// <param name="resultVector">The result vector of the linear equation system.</param>
        public LinearEquationSystem(Matrix coefficientMatrix, GeneralVector resultVector)
        {
            if (coefficientMatrix.Rows != resultVector.Count)
            {
                throw new NotConfortableException(
                    "The number of rows of the coefficient matrix and the result vector have to be even.");
            }

            this.coefficientMatrix = coefficientMatrix;
            this.resultVector = resultVector;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="LinearEquationSystem"/> class.
        /// </summary>
        /// <param name="equationSystem">The LinearEquationSystem to clone.</param>
        public LinearEquationSystem(LinearEquationSystem equationSystem)
        {
            this.coefficientMatrix = equationSystem.CoefficientMatrix.Copy();
            this.resultVector = equationSystem.ResultVector.Copy();
        }

        /// <summary>
        /// Gets or sets the coefficient matrix of the linear equation system.
        /// </summary>
        /// <value>The coefficient matrix of the linear equation system.</value>
        public Matrix CoefficientMatrix
        {
            get { return coefficientMatrix; }
            set { coefficientMatrix = value; }
        }

        /// <summary>
        /// Gets or sets the result vector of the linear equation system.
        /// </summary>
        /// <value>The result vector of the linear equation system.</value>
        public GeneralVector ResultVector
        {
            get { return resultVector; }
            set { resultVector = value; }
        }
    }
}